<!--
 * @Author: wankong
 * @Date: 2021-10-07 19:57:45
 * @LastEditTime: 2021-10-19 15:10:58
-->
<template>
  <div class="welcome">
    <el-row :gutter="20">
      <el-col :span="6">
        <el-card>
          <template slot="header">文章统计</template>
          共
          <span style="font-size: 40px; color: #ff5e5c">{{ config.blog }}</span>
          篇
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card>
          <template slot="header">标签统计</template> 共
          <span style="font-size: 40px; color: #ffbb50">{{ config.tags }}</span
          >个</el-card
        >
      </el-col>
      <el-col :span="6">
        <el-card>
          <template slot="header">评论统计</template> 共
          <span style="font-size: 40px; color: #1ac756">{{
            config.comments
          }}</span
          >条</el-card
        >
      </el-col>
      <el-col :span="6">
        <el-card>
          <template slot="header">友链统计</template> 共
          <span style="font-size: 40px; color: #19b5fe">{{ config.links }}</span
          >个</el-card
        >
      </el-col>
    </el-row>
    <br />
    <el-row :gutter="20">
      <el-col :span="6">
        <el-card>
          <template slot="header">最热文章</template>
          <a @click="GoArticle()"
            >《{{ config.hots.title }}》<br />浏览量:<span
              style="font-size: 40px; color: #19b5fe"
              >{{ config.hots.views }}</span
            ></a
          >
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      config: {
        blog: 0,
        tags: 0,
        links: 0,
        comments: 0,
        hots: {
          title: "",
          views: 0,
          id: 0,
        },
      },
    };
  },
  methods: {
    async getCount() {
      const res = await this.$http.get(`${this.adminPre}/tongji`);
      this.config = res.data;
    },

    GoArticle() {
      const url = this.$router.resolve({
        path: `/article/${this.config.hots.id}`,
      });
      window.open(url.href, "_blank");
    },
  },
  created() {
    this.getCount();
  },
};
</script>

<style>
</style>